package com.cuijq.ms.strategy.v2.impl;

import com.cuijq.ms.strategy.v2.DiscountStrategy;
import com.cuijq.ms.strategy.v2.OrderType;
import java.util.HashMap;
import java.util.Map;

/**
 * @author by CuiJQ
 * @Classname DiscountStrategyFactory
 * @Description DiscountStrategyFactory Description
 * @Date 2021/5/28 21:01
 */
public class DiscountStrategyFactory2 {

  public static DiscountStrategy getDiscountStrategy(OrderType type) {
    if (type == null) {
      throw new IllegalArgumentException("Type should not be null.");
    }
    if (type.equals(OrderType.NORMAL)) {
      return new NormalDiscountStrategy();
    } else if (type.equals(OrderType.GROUPON)) {
      return new GrouponDiscountStrategy();
    } else if (type.equals(OrderType.PROMOTION)) {
      return new PromotionDiscountStrategy();
    }
    return null;
  }
}
